package com.ruoyi.info.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.info.domain.ProductForm;
import com.ruoyi.info.service.IProductFormService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 产品形态Controller
 * 
 * @author wangshi
 * @date 2023-06-10
 */
@RestController
@RequestMapping("/info/productForm")
public class ProductFormController extends BaseController
{
    @Autowired
    private IProductFormService productFormService;

    /**
     * 查询产品形态列表
     */
    @PreAuthorize("@ss.hasPermi('info:productForm:list')")
    @GetMapping("/list")
    public AjaxResult list(ProductForm productForm)
    {
        List<ProductForm> list = productFormService.selectProductFormList(productForm);
        return success(list);
    }

    /**
     * 导出产品形态列表
     */
    @PreAuthorize("@ss.hasPermi('info:productForm:export')")
    @Log(title = "产品形态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductForm productForm)
    {
        List<ProductForm> list = productFormService.selectProductFormList(productForm);
        ExcelUtil<ProductForm> util = new ExcelUtil<ProductForm>(ProductForm.class);
        util.exportExcel(response, list, "产品形态数据");
    }

    /**
     * 获取产品形态详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:productForm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productFormService.selectProductFormById(id));
    }

    /**
     * 新增产品形态
     */
    @PreAuthorize("@ss.hasPermi('info:productForm:add')")
    @Log(title = "产品形态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductForm productForm)
    {
        return toAjax(productFormService.insertProductForm(productForm));
    }

    /**
     * 修改产品形态
     */
    @PreAuthorize("@ss.hasPermi('info:productForm:edit')")
    @Log(title = "产品形态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductForm productForm)
    {
        return toAjax(productFormService.updateProductForm(productForm));
    }

    /**
     * 删除产品形态
     */
    @PreAuthorize("@ss.hasPermi('info:productForm:remove')")
    @Log(title = "产品形态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productFormService.deleteProductFormByIds(ids));
    }
}
